package jcpcotizaciones.vista;

import java.sql.SQLException;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import javax.swing.table.DefaultTableModel;
import jcpcotizaciones.Control.*;
import jcpcotizaciones.JCPCOTIZACIONESApp;
import jcpcotizaciones.JCPCOTIZACIONESView;
import jcpcotizaciones.Modelo.*;
import jcpcotizaciones.reportes.GenerarReporte;

public class vistaCotizacion extends javax.swing.JFrame {

    public vistaCotizacion() {
        initComponents();
        parametros();
    }


    DefaultTableModel dtm = new DefaultTableModel();
    int contadoritem=0;
    FormatoSimple fs = new FormatoSimple();
    public void parametros(){
        DecimalFormat formateador = new DecimalFormat("0000");
            if(ControlCotizacion.proximo()==0){
                tx_numero.setText(formateador.format(1));
            } else{
                tx_numero.setText(""+ formateador.format(ControlCotizacion.proximo()));
            }
        Date fecha = new Date();
        SimpleDateFormat formato = new SimpleDateFormat(" dd-MM-yyyy ");
        String sfecha = formato.format(fecha);
        tx_fecha.setText(sfecha);

        Date hora = new Date();
        SimpleDateFormat formatohora = new SimpleDateFormat("hh:mm a");
        String shora = formatohora.format(hora);
        tx_hora.setText(shora);
    }

    public void buscar(){
        String item = cb_buscarcli.getSelectedItem().toString();
        Cliente cli;
    try {
        if(tx_buscarcli.getText().trim().equals("")){
            JOptionPane.showMessageDialog(null,"Por favor digite un criterio de busqueda.");
            }else{
                if(item.equals("Código")){
                 cli = ControlCliente.BuscarCliente(tx_buscarcli.getText());
                }else{
                    if(item.equals("Cédula")){
                    cli = ControlCliente.BuscarClienteCed(tx_buscarcli.getText());
                    }else{
                        cli = ControlCliente.BuscarClienteNom(tx_buscarcli.getText());
                    }
                }
                if(cli != null){
                    tx_codigocli.setText(cli.getCodigo());
                    tx_cedulacli.setText(cli.getCedula());
                    tx_nombrecli.setText(cli.getNombre());
                    tx_direccioncli.setText(cli.getDireccion());
                    tx_telefonocli.setText(cli.getTelefono());
                    tx_emailcli.setText(cli.getEmail());
                    tx_buscarcli.setText("");
                }else{
                    JOptionPane.showMessageDialog(null,"Cliente no encontrado.");
                }
            }
        } catch (SQLException ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        dialogo = new javax.swing.JDialog();
        Aceptar_eliminar = new javax.swing.JButton();
        jLabel24 = new javax.swing.JLabel();
        Cancelar_Eliminar = new javax.swing.JButton();
        jDial_formatosimple = new javax.swing.JDialog();
        jPanel1 = new javax.swing.JPanel();
        pisoCotizacion = new jcMousePanel.jcMousePanel();
        jcMousePanel2 = new jcMousePanel.jcMousePanel();
        jcMousePanel3 = new jcMousePanel.jcMousePanel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        tx_codigocli = new javax.swing.JTextField();
        tx_nombrecli = new javax.swing.JTextField();
        tx_telefonocli = new javax.swing.JTextField();
        tx_emailcli = new javax.swing.JTextField();
        tx_direccioncli = new javax.swing.JTextField();
        jLabel18 = new javax.swing.JLabel();
        tx_cedulacli = new javax.swing.JTextField();
        jcMousePanel4 = new jcMousePanel.jcMousePanel();
        cb_buscarcli = new javax.swing.JComboBox();
        jLabel1 = new javax.swing.JLabel();
        tx_buscarcli = new javax.swing.JTextField();
        bt_buscarcliente = new javax.swing.JButton();
        tx_fecha = new javax.swing.JTextField();
        jLabel2 = new javax.swing.JLabel();
        tx_numero = new javax.swing.JTextField();
        jLabel3 = new javax.swing.JLabel();
        jcMousePanel5 = new jcMousePanel.jcMousePanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        tablaitem = new javax.swing.JTable(dtm);
        jLabel14 = new javax.swing.JLabel();
        tx_subtotal = new javax.swing.JTextField();
        tx_iva = new javax.swing.JTextField();
        tx_totalcotizacion = new javax.swing.JTextField();
        jLabel15 = new javax.swing.JLabel();
        jLabel16 = new javax.swing.JLabel();
        jLabel17 = new javax.swing.JLabel();
        bt_cancelar = new javax.swing.JButton();
        bt_guardar = new javax.swing.JButton();
        bt_quitar = new javax.swing.JButton();
        bt_nuevacotizacion = new javax.swing.JButton();
        bt_imprimir = new javax.swing.JButton();
        tx_hora = new javax.swing.JTextField();
        jLabel23 = new javax.swing.JLabel();
        jcMousePanel1 = new jcMousePanel.jcMousePanel();
        jButton1 = new javax.swing.JButton();

        dialogo.setName("dialogo"); // NOI18N

        org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(jcpcotizaciones.JCPCOTIZACIONESApp.class).getContext().getResourceMap(vistaCotizacion.class);
        Aceptar_eliminar.setText(resourceMap.getString("Aceptar_eliminar.text")); // NOI18N
        Aceptar_eliminar.setName("Aceptar_eliminar"); // NOI18N
        Aceptar_eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Aceptar_eliminarActionPerformed(evt);
            }
        });

        jLabel24.setText(resourceMap.getString("jLabel24.text")); // NOI18N
        jLabel24.setName("jLabel24"); // NOI18N

        Cancelar_Eliminar.setText(resourceMap.getString("Cancelar_Eliminar.text")); // NOI18N
        Cancelar_Eliminar.setName("Cancelar_Eliminar"); // NOI18N
        Cancelar_Eliminar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                Cancelar_EliminarActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout dialogoLayout = new javax.swing.GroupLayout(dialogo.getContentPane());
        dialogo.getContentPane().setLayout(dialogoLayout);
        dialogoLayout.setHorizontalGroup(
            dialogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 388, Short.MAX_VALUE)
            .addGroup(dialogoLayout.createSequentialGroup()
                .addGap(144, 144, 144)
                .addGroup(dialogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(dialogoLayout.createSequentialGroup()
                        .addComponent(Aceptar_eliminar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Cancelar_Eliminar))
                    .addComponent(jLabel24, javax.swing.GroupLayout.PREFERRED_SIZE, 197, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(47, 47, 47))
        );
        dialogoLayout.setVerticalGroup(
            dialogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(dialogoLayout.createSequentialGroup()
                .addGap(21, 21, 21)
                .addComponent(jLabel24)
                .addGap(33, 33, 33)
                .addGroup(dialogoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(Aceptar_eliminar)
                    .addComponent(Cancelar_Eliminar))
                .addContainerGap(41, Short.MAX_VALUE))
        );

        jDial_formatosimple.setModal(true);
        jDial_formatosimple.setName("jDial_formatosimple"); // NOI18N
        jDial_formatosimple.setTitle("Formato Simple");

        jPanel1.setMaximumSize(new java.awt.Dimension(650, 450));
        jPanel1.setMinimumSize(new java.awt.Dimension(650, 450));
        jPanel1.setName("jPanel1"); // NOI18N
        jPanel1.setPreferredSize(new java.awt.Dimension(650, 450));
        jPanel1.add(fs.piso_formato);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 1135, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 450, Short.MAX_VALUE)
        );

        javax.swing.GroupLayout jDial_formatosimpleLayout = new javax.swing.GroupLayout(jDial_formatosimple.getContentPane());
        jDial_formatosimple.getContentPane().setLayout(jDial_formatosimpleLayout);
        jDial_formatosimpleLayout.setHorizontalGroup(
            jDial_formatosimpleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jDial_formatosimpleLayout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 1135, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(189, Short.MAX_VALUE))
        );
        jDial_formatosimpleLayout.setVerticalGroup(
            jDial_formatosimpleLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
        setMinimumSize(new java.awt.Dimension(748, 775));
        setName("Form"); // NOI18N
        setResizable(false);

        pisoCotizacion.setIcon(resourceMap.getIcon("pisoCotizacion.icon")); // NOI18N
        pisoCotizacion.setName("pisoCotizacion"); // NOI18N

        jcMousePanel2.setIcon(resourceMap.getIcon("jcMousePanel2.icon")); // NOI18N
        jcMousePanel2.setName("jcMousePanel2"); // NOI18N

        javax.swing.GroupLayout jcMousePanel2Layout = new javax.swing.GroupLayout(jcMousePanel2);
        jcMousePanel2.setLayout(jcMousePanel2Layout);
        jcMousePanel2Layout.setHorizontalGroup(
            jcMousePanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 304, Short.MAX_VALUE)
        );
        jcMousePanel2Layout.setVerticalGroup(
            jcMousePanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 55, Short.MAX_VALUE)
        );

        jcMousePanel3.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jcMousePanel3.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jcMousePanel3.border.titleFont"), resourceMap.getColor("jcMousePanel3.border.titleColor"))); // NOI18N
        jcMousePanel3.setIcon(resourceMap.getIcon("jcMousePanel3.icon")); // NOI18N
        jcMousePanel3.setName("jcMousePanel3"); // NOI18N

        jLabel4.setText(resourceMap.getString("jLabel4.text")); // NOI18N
        jLabel4.setName("jLabel4"); // NOI18N

        jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
        jLabel5.setName("jLabel5"); // NOI18N

        jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
        jLabel6.setName("jLabel6"); // NOI18N

        jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
        jLabel7.setName("jLabel7"); // NOI18N

        jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
        jLabel8.setName("jLabel8"); // NOI18N

        tx_codigocli.setText(resourceMap.getString("tx_codigocli.text")); // NOI18N
        tx_codigocli.setEnabled(false);
        tx_codigocli.setName("tx_codigocli"); // NOI18N

        tx_nombrecli.setText(resourceMap.getString("tx_nombrecli.text")); // NOI18N
        tx_nombrecli.setEnabled(false);
        tx_nombrecli.setName("tx_nombrecli"); // NOI18N

        tx_telefonocli.setText(resourceMap.getString("tx_telefonocli.text")); // NOI18N
        tx_telefonocli.setEnabled(false);
        tx_telefonocli.setName("tx_telefonocli"); // NOI18N

        tx_emailcli.setText(resourceMap.getString("tx_emailcli.text")); // NOI18N
        tx_emailcli.setEnabled(false);
        tx_emailcli.setName("tx_emailcli"); // NOI18N

        tx_direccioncli.setText(resourceMap.getString("tx_direccioncli.text")); // NOI18N
        tx_direccioncli.setEnabled(false);
        tx_direccioncli.setName("tx_direccioncli"); // NOI18N

        jLabel18.setText(resourceMap.getString("jLabel18.text")); // NOI18N
        jLabel18.setName("jLabel18"); // NOI18N

        tx_cedulacli.setText(resourceMap.getString("tx_cedulacli.text")); // NOI18N
        tx_cedulacli.setEnabled(false);
        tx_cedulacli.setName("tx_cedulacli"); // NOI18N

        javax.swing.GroupLayout jcMousePanel3Layout = new javax.swing.GroupLayout(jcMousePanel3);
        jcMousePanel3.setLayout(jcMousePanel3Layout);
        jcMousePanel3Layout.setHorizontalGroup(
            jcMousePanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jcMousePanel3Layout.createSequentialGroup()
                .addGroup(jcMousePanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jcMousePanel3Layout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tx_direccioncli, javax.swing.GroupLayout.PREFERRED_SIZE, 238, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jcMousePanel3Layout.createSequentialGroup()
                        .addComponent(jLabel4)
                        .addGap(18, 18, 18)
                        .addComponent(tx_codigocli, javax.swing.GroupLayout.PREFERRED_SIZE, 76, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(jLabel18)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tx_cedulacli, javax.swing.GroupLayout.PREFERRED_SIZE, 123, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jcMousePanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jcMousePanel3Layout.createSequentialGroup()
                        .addComponent(jLabel6)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tx_telefonocli, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(tx_emailcli, javax.swing.GroupLayout.DEFAULT_SIZE, 111, Short.MAX_VALUE))
                    .addGroup(jcMousePanel3Layout.createSequentialGroup()
                        .addComponent(jLabel5)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(tx_nombrecli, javax.swing.GroupLayout.DEFAULT_SIZE, 273, Short.MAX_VALUE)))
                .addContainerGap())
        );
        jcMousePanel3Layout.setVerticalGroup(
            jcMousePanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jcMousePanel3Layout.createSequentialGroup()
                .addGroup(jcMousePanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(tx_codigocli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(tx_nombrecli, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel18)
                    .addComponent(tx_cedulacli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jcMousePanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel7)
                    .addComponent(tx_emailcli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tx_direccioncli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(tx_telefonocli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel8)))
        );

        jcMousePanel4.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jcMousePanel4.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jcMousePanel4.border.titleFont"), resourceMap.getColor("jcMousePanel4.border.titleColor"))); // NOI18N
        jcMousePanel4.setIcon(resourceMap.getIcon("jcMousePanel4.icon")); // NOI18N
        jcMousePanel4.setName("jcMousePanel4"); // NOI18N

        cb_buscarcli.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Código", "Cédula", "Nombre" }));
        cb_buscarcli.setName("cb_buscarcli"); // NOI18N

        jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
        jLabel1.setName("jLabel1"); // NOI18N

        tx_buscarcli.setText(resourceMap.getString("tx_buscarcli.text")); // NOI18N
        tx_buscarcli.setName("tx_buscarcli"); // NOI18N
        tx_buscarcli.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tx_buscarcliActionPerformed(evt);
            }
        });

        bt_buscarcliente.setIcon(resourceMap.getIcon("bt_buscarcliente.icon")); // NOI18N
        bt_buscarcliente.setText(resourceMap.getString("bt_buscarcliente.text")); // NOI18N
        bt_buscarcliente.setName("bt_buscarcliente"); // NOI18N
        bt_buscarcliente.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_buscarclienteActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jcMousePanel4Layout = new javax.swing.GroupLayout(jcMousePanel4);
        jcMousePanel4.setLayout(jcMousePanel4Layout);
        jcMousePanel4Layout.setHorizontalGroup(
            jcMousePanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jcMousePanel4Layout.createSequentialGroup()
                .addComponent(cb_buscarcli, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jLabel1)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(tx_buscarcli, javax.swing.GroupLayout.PREFERRED_SIZE, 102, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(bt_buscarcliente))
        );
        jcMousePanel4Layout.setVerticalGroup(
            jcMousePanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jcMousePanel4Layout.createSequentialGroup()
                .addGroup(jcMousePanel4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(cb_buscarcli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel1)
                    .addComponent(tx_buscarcli, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(bt_buscarcliente))
                .addContainerGap(31, Short.MAX_VALUE))
        );

        tx_fecha.setFont(resourceMap.getFont("tx_fecha.font")); // NOI18N
        tx_fecha.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        tx_fecha.setText(resourceMap.getString("tx_fecha.text")); // NOI18N
        tx_fecha.setEnabled(false);
        tx_fecha.setName("tx_fecha"); // NOI18N

        jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
        jLabel2.setName("jLabel2"); // NOI18N

        tx_numero.setFont(resourceMap.getFont("tx_numero.font")); // NOI18N
        tx_numero.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        tx_numero.setText(resourceMap.getString("tx_numero.text")); // NOI18N
        tx_numero.setBorder(null);
        tx_numero.setEnabled(false);
        tx_numero.setName("tx_numero"); // NOI18N
        tx_numero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tx_numeroActionPerformed(evt);
            }
        });

        jLabel3.setFont(resourceMap.getFont("jLabel3.font")); // NOI18N
        jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
        jLabel3.setName("jLabel3"); // NOI18N

        jcMousePanel5.setBorder(javax.swing.BorderFactory.createTitledBorder(null, resourceMap.getString("jcMousePanel5.border.title"), javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, resourceMap.getFont("jcMousePanel5.border.titleFont"), resourceMap.getColor("jcMousePanel5.border.titleColor"))); // NOI18N
        jcMousePanel5.setIcon(resourceMap.getIcon("jcMousePanel5.icon")); // NOI18N
        jcMousePanel5.setName("jcMousePanel5"); // NOI18N

        jScrollPane1.setName("jScrollPane1"); // NOI18N

        dtm.addColumn("Numero");
        dtm.addColumn("Cantidad");
        dtm.addColumn("Descripción");
        dtm.addColumn("Tamaño");
        dtm.addColumn("Papel");
        dtm.addColumn("Tintas");
        dtm.addColumn("Vr. Unitario");
        dtm.addColumn("Vr. Total");
        tablaitem.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF);
        tablaitem.setName("tablaitem"); // NOI18N
        jScrollPane1.setViewportView(tablaitem);

        jLabel14.setFont(resourceMap.getFont("jLabel14.font")); // NOI18N
        jLabel14.setText(resourceMap.getString("jLabel14.text")); // NOI18N
        jLabel14.setName("jLabel14"); // NOI18N

        tx_subtotal.setEditable(false);
        tx_subtotal.setText(resourceMap.getString("tx_subtotal.text")); // NOI18N
        tx_subtotal.setName("tx_subtotal"); // NOI18N

        tx_iva.setEditable(false);
        tx_iva.setText(resourceMap.getString("tx_iva.text")); // NOI18N
        tx_iva.setName("tx_iva"); // NOI18N

        tx_totalcotizacion.setEditable(false);
        tx_totalcotizacion.setText(resourceMap.getString("tx_totalcotizacion.text")); // NOI18N
        tx_totalcotizacion.setName("tx_totalcotizacion"); // NOI18N

        jLabel15.setFont(resourceMap.getFont("jLabel15.font")); // NOI18N
        jLabel15.setText(resourceMap.getString("jLabel15.text")); // NOI18N
        jLabel15.setName("jLabel15"); // NOI18N

        jLabel16.setFont(resourceMap.getFont("jLabel16.font")); // NOI18N
        jLabel16.setText(resourceMap.getString("jLabel16.text")); // NOI18N
        jLabel16.setName("jLabel16"); // NOI18N

        jLabel17.setFont(resourceMap.getFont("jLabel17.font")); // NOI18N
        jLabel17.setText(resourceMap.getString("jLabel17.text")); // NOI18N
        jLabel17.setName("jLabel17"); // NOI18N

        bt_cancelar.setIcon(resourceMap.getIcon("bt_cancelar.icon")); // NOI18N
        bt_cancelar.setText(resourceMap.getString("bt_cancelar.text")); // NOI18N
        bt_cancelar.setToolTipText(resourceMap.getString("bt_cancelar.toolTipText")); // NOI18N
        bt_cancelar.setName("bt_cancelar"); // NOI18N
        bt_cancelar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_cancelarActionPerformed(evt);
            }
        });

        bt_guardar.setIcon(resourceMap.getIcon("bt_guardar.icon")); // NOI18N
        bt_guardar.setText(resourceMap.getString("bt_guardar.text")); // NOI18N
        bt_guardar.setToolTipText(resourceMap.getString("bt_guardar.toolTipText")); // NOI18N
        bt_guardar.setName("bt_guardar"); // NOI18N
        bt_guardar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_guardarActionPerformed(evt);
            }
        });

        bt_quitar.setIcon(resourceMap.getIcon("bt_quitar.icon")); // NOI18N
        bt_quitar.setText(resourceMap.getString("bt_quitar.text")); // NOI18N
        bt_quitar.setToolTipText(resourceMap.getString("bt_quitar.toolTipText")); // NOI18N
        bt_quitar.setName("bt_quitar"); // NOI18N
        bt_quitar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_quitarActionPerformed(evt);
            }
        });

        bt_nuevacotizacion.setIcon(resourceMap.getIcon("bt_nuevacotizacion.icon")); // NOI18N
        bt_nuevacotizacion.setText(resourceMap.getString("bt_nuevacotizacion.text")); // NOI18N
        bt_nuevacotizacion.setToolTipText(resourceMap.getString("bt_nuevacotizacion.toolTipText")); // NOI18N
        bt_nuevacotizacion.setName("bt_nuevacotizacion"); // NOI18N
        bt_nuevacotizacion.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_nuevacotizacionActionPerformed(evt);
            }
        });

        bt_imprimir.setIcon(resourceMap.getIcon("bt_imprimir.icon")); // NOI18N
        bt_imprimir.setText(resourceMap.getString("bt_imprimir.text")); // NOI18N
        bt_imprimir.setName("bt_imprimir"); // NOI18N
        bt_imprimir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                bt_imprimirActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jcMousePanel5Layout = new javax.swing.GroupLayout(jcMousePanel5);
        jcMousePanel5.setLayout(jcMousePanel5Layout);
        jcMousePanel5Layout.setHorizontalGroup(
            jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 625, Short.MAX_VALUE)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jcMousePanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(jcMousePanel5Layout.createSequentialGroup()
                        .addComponent(bt_quitar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(bt_imprimir)
                        .addGap(6, 6, 6)
                        .addComponent(bt_nuevacotizacion)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_guardar)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(bt_cancelar))
                    .addGroup(jcMousePanel5Layout.createSequentialGroup()
                        .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(jLabel15)
                            .addComponent(jLabel16)
                            .addComponent(jLabel17))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tx_totalcotizacion, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tx_iva, javax.swing.GroupLayout.Alignment.TRAILING)
                            .addComponent(tx_subtotal, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 146, javax.swing.GroupLayout.PREFERRED_SIZE)))))
            .addGroup(jcMousePanel5Layout.createSequentialGroup()
                .addGap(172, 172, 172)
                .addComponent(jLabel14)
                .addContainerGap(188, Short.MAX_VALUE))
        );
        jcMousePanel5Layout.setVerticalGroup(
            jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jcMousePanel5Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jLabel14)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 251, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tx_subtotal, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel15))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tx_iva, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel16))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(tx_totalcotizacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel17))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jcMousePanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(bt_nuevacotizacion)
                    .addComponent(bt_guardar)
                    .addComponent(bt_cancelar)
                    .addComponent(bt_imprimir)
                    .addComponent(bt_quitar)))
        );

        tx_hora.setEditable(false);
        tx_hora.setFont(resourceMap.getFont("tx_hora.font")); // NOI18N
        tx_hora.setHorizontalAlignment(javax.swing.JTextField.CENTER);
        tx_hora.setText(resourceMap.getString("tx_hora.text")); // NOI18N
        tx_hora.setEnabled(false);
        tx_hora.setName("tx_hora"); // NOI18N
        tx_hora.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                tx_horaActionPerformed(evt);
            }
        });

        jLabel23.setText(resourceMap.getString("jLabel23.text")); // NOI18N
        jLabel23.setName("jLabel23"); // NOI18N

        jcMousePanel1.setIcon(resourceMap.getIcon("jcMousePanel1.icon")); // NOI18N
        jcMousePanel1.setName("jcMousePanel1"); // NOI18N

        jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
        jButton1.setName("jButton1"); // NOI18N
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jcMousePanel1Layout = new javax.swing.GroupLayout(jcMousePanel1);
        jcMousePanel1.setLayout(jcMousePanel1Layout);
        jcMousePanel1Layout.setHorizontalGroup(
            jcMousePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jcMousePanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jButton1)
                .addContainerGap(526, Short.MAX_VALUE))
        );
        jcMousePanel1Layout.setVerticalGroup(
            jcMousePanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jcMousePanel1Layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jButton1)
                .addContainerGap())
        );

        javax.swing.GroupLayout pisoCotizacionLayout = new javax.swing.GroupLayout(pisoCotizacion);
        pisoCotizacion.setLayout(pisoCotizacionLayout);
        pisoCotizacionLayout.setHorizontalGroup(
            pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pisoCotizacionLayout.createSequentialGroup()
                .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pisoCotizacionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(jcMousePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(tx_hora)
                            .addComponent(jLabel2)
                            .addComponent(tx_fecha, javax.swing.GroupLayout.DEFAULT_SIZE, 98, Short.MAX_VALUE)
                            .addComponent(jLabel23))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(tx_numero, javax.swing.GroupLayout.DEFAULT_SIZE, 107, Short.MAX_VALUE)
                            .addComponent(jLabel3)))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pisoCotizacionLayout.createSequentialGroup()
                        .addGap(213, 213, 213)
                        .addComponent(jcMousePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, pisoCotizacionLayout.createSequentialGroup()
                        .addContainerGap()
                        .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                            .addComponent(jcMousePanel3, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jcMousePanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                            .addComponent(jcMousePanel5, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        pisoCotizacionLayout.setVerticalGroup(
            pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(pisoCotizacionLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jcMousePanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jcMousePanel4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(pisoCotizacionLayout.createSequentialGroup()
                        .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(pisoCotizacionLayout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addGap(1, 1, 1)
                                .addComponent(tx_fecha, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(jLabel3))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(pisoCotizacionLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                            .addGroup(pisoCotizacionLayout.createSequentialGroup()
                                .addComponent(jLabel23)
                                .addGap(9, 9, 9)
                                .addComponent(tx_hora, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                            .addComponent(tx_numero, javax.swing.GroupLayout.DEFAULT_SIZE, 49, Short.MAX_VALUE))))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jcMousePanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jcMousePanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jcMousePanel5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(pisoCotizacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(pisoCotizacion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void tx_buscarcliActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tx_buscarcliActionPerformed
        buscar();
    }//GEN-LAST:event_tx_buscarcliActionPerformed

    private void bt_buscarclienteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_buscarclienteActionPerformed
        buscar();
    }//GEN-LAST:event_bt_buscarclienteActionPerformed

    private void tx_numeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tx_numeroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tx_numeroActionPerformed

    private void tx_horaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_tx_horaActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_tx_horaActionPerformed

    private void bt_guardarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_guardarActionPerformed
        guardarCotizacion();
       tx_codigocli.setText("");
       tx_cedulacli.setText("");
       tx_nombrecli.setText("");
       tx_direccioncli.setText("");
       tx_telefonocli.setText("");
       tx_emailcli.setText("");
       tx_subtotal.setText("0.0");
       tx_iva.setText("0.0");
       tx_totalcotizacion.setText("0.0");

       dtm.setNumRows(0);
       parametros();
       JCPCOTIZACIONESView.frame_cotizacion.setVisible(false);
    }//GEN-LAST:event_bt_guardarActionPerformed

    private void bt_cancelarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_cancelarActionPerformed
       
        
       try {
            if(ControlCotizacion.BuscarCotizacion(tx_numero.getText().trim())!=null){
                ControlItem.EliminarItemCotizacion(tx_numero.getText().trim());
                ControlCotizacion.EliminarCotizacion(tx_numero.getText().trim());
            }
       tx_codigocli.setText("");
       tx_cedulacli.setText("");
       tx_nombrecli.setText("");
       tx_direccioncli.setText("");
       tx_telefonocli.setText("");
       tx_emailcli.setText("");
       tx_subtotal.setText("0.0");
       tx_iva.setText("0.0");
       tx_totalcotizacion.setText("0.0");
       dtm.setNumRows(0);
       parametros();
  
            JCPCOTIZACIONESView.frame_cotizacion.setVisible(false);
       
        } catch (SQLException ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }//GEN-LAST:event_bt_cancelarActionPerformed

    private void bt_quitarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_quitarActionPerformed

            dialogo.setSize(350, 150);
            dialogo.setLocation(350, 300);
            dialogo.setVisible(true);
    }//GEN-LAST:event_bt_quitarActionPerformed

    private void Aceptar_eliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Aceptar_eliminarActionPerformed

    try {

            int x = tablaitem.getSelectedRow();
            String num = dtm.getValueAt(x, 0).toString();
            ControlItem.EliminarItem(num);
            listarItem();

        } catch (SQLException ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
        dialogo.setVisible(false);

}//GEN-LAST:event_Aceptar_eliminarActionPerformed

    private void Cancelar_EliminarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Cancelar_EliminarActionPerformed
       dialogo.setVisible(false);
}//GEN-LAST:event_Cancelar_EliminarActionPerformed

    private void bt_nuevacotizacionActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_nuevacotizacionActionPerformed
       guardarCotizacion();
       tx_codigocli.setText("");
       tx_cedulacli.setText("");
       tx_nombrecli.setText("");
       tx_direccioncli.setText("");
       tx_telefonocli.setText("");
       tx_emailcli.setText("");
       tx_subtotal.setText("0.0");
       tx_iva.setText("0.0");
       tx_totalcotizacion.setText("0.0");
       dtm.setNumRows(0);
       parametros();
       

    }//GEN-LAST:event_bt_nuevacotizacionActionPerformed

    private void bt_imprimirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_bt_imprimirActionPerformed
        GenerarReporte.generarReporteAbsoluto("C:\\reportes\\ReporCotizacion.jasper", tx_numero.getText(),"NumCotizacion");

       // GenerarReporte.generarReporte("../reportes/ReporCotizacion.jasper", tx_numero.getText());

    }//GEN-LAST:event_bt_imprimirActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
        
        
        contadoritem+=1;
        DecimalFormat formateador = new DecimalFormat("00");
        String contitem = formateador.format(contadoritem);
        fs.tx_num_item.setText(tx_numero.getText()+" - "+contitem);
        fs.setVc(this);
        jDial_formatosimple.setSize(650, 450);
        jDial_formatosimple.setLocation(350, 300);
        jDial_formatosimple.setVisible(true);
        
    }//GEN-LAST:event_jButton1ActionPerformed

  public void agregarCotizacion(){
    if (tx_codigocli.getText().trim().equals("")){
        JOptionPane.showMessageDialog(null,"Seleccione un Cliente");
    }else{
            try {
                Cotizacion c = new Cotizacion();
                c.setNumero(tx_numero.getText());
                c.setFecha(tx_fecha.getText());
                c.setHora(tx_hora.getText());
                c.setSubtotal(Double.parseDouble(tx_subtotal.getText()));
                c.setIva(Double.parseDouble(tx_iva.getText()));
                c.setTotal(Double.parseDouble(tx_totalcotizacion.getText()));
                c.setCliente(ControlCliente.BuscarCliente(tx_codigocli.getText()));
                c.setUsuario(JCPCOTIZACIONESApp.usu);
                ControlCotizacion.agregarCotizacion(c);
                contadoritem = 0;
            } catch (SQLException ex) {
                Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
            } catch (Exception ex) {
                Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
            }
    }

}





public void listarItem(){
        Item i = new Item();
        double acumulador=0;
        try {
            dtm.setNumRows(0);
            ControlItem.listarItem();
            Iterator it = ControlItem.getItem().iterator();
                while (it.hasNext()) {
                    i = (Item) it.next();
                    if (i.getCotizacion().getNumero().equals(tx_numero.getText())){
                    String[] fila = {i.getNumero(), Integer.toString(i.getCantidad()), i.getDescripcion(), i.getCortepapel().getNombre(), i.getTipopapel().getNombre(),Integer.toString(i.getTiro())+"x"+ Integer.toString(i.getRetiro()), Double.toString(i.getValorunitario()), Double.toString(i.getValortotal())};
                    dtm.addRow(fila);
                    acumulador += i.getValortotal();
                    tx_subtotal.setText(Double.toString(acumulador));
                    double iva = acumulador * 16 / 100;
                    tx_iva.setText(Double.toString(iva));
                    tx_totalcotizacion.setText(Double.toString(acumulador + iva));

                    }
                }
        } catch (SQLException ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
    }

   

    public void guardarCotizacion(){
        
        try {
                if(ControlCotizacion.BuscarCotizacion(tx_numero.getText())!= null){
                    Cotizacion c = new Cotizacion();
                    c.setNumero(tx_numero.getText());
                    c.setFecha(tx_fecha.getText());
                    c.setHora(tx_hora.getText());
                    c.setSubtotal(Double.parseDouble(tx_subtotal.getText()));
                    c.setIva(Double.parseDouble(tx_iva.getText()));
                    c.setTotal(Double.parseDouble(tx_totalcotizacion.getText()));
                    c.setCliente(ControlCliente.BuscarCliente(tx_codigocli.getText()));
                    c.setUsuario(JCPCOTIZACIONESApp.usu);
                    ControlCotizacion.ModificarCotizacion(c, tx_numero.getText());
                } else{
                    JOptionPane.showMessageDialog(null,"La cotizacion Numero "+tx_numero.getText()+" no tiene Item");
                }
        } catch (SQLException ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        } catch (Exception ex) {
            Logger.getLogger(vistaCotizacion.class.getName()).log(Level.SEVERE, null, ex);
        }
        
    }

    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton Aceptar_eliminar;
    private javax.swing.JButton Cancelar_Eliminar;
    private javax.swing.JButton bt_buscarcliente;
    private javax.swing.JButton bt_cancelar;
    private javax.swing.JButton bt_guardar;
    private javax.swing.JButton bt_imprimir;
    private javax.swing.JButton bt_nuevacotizacion;
    private javax.swing.JButton bt_quitar;
    private javax.swing.JComboBox cb_buscarcli;
    private javax.swing.JDialog dialogo;
    private javax.swing.JButton jButton1;
    public javax.swing.JDialog jDial_formatosimple;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel14;
    private javax.swing.JLabel jLabel15;
    private javax.swing.JLabel jLabel16;
    private javax.swing.JLabel jLabel17;
    private javax.swing.JLabel jLabel18;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel23;
    private javax.swing.JLabel jLabel24;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private jcMousePanel.jcMousePanel jcMousePanel1;
    private jcMousePanel.jcMousePanel jcMousePanel2;
    private jcMousePanel.jcMousePanel jcMousePanel3;
    private jcMousePanel.jcMousePanel jcMousePanel4;
    private jcMousePanel.jcMousePanel jcMousePanel5;
    public static jcMousePanel.jcMousePanel pisoCotizacion;
    private javax.swing.JTable tablaitem;
    private javax.swing.JTextField tx_buscarcli;
    private javax.swing.JTextField tx_cedulacli;
    private javax.swing.JTextField tx_codigocli;
    private javax.swing.JTextField tx_direccioncli;
    private javax.swing.JTextField tx_emailcli;
    private javax.swing.JTextField tx_fecha;
    private javax.swing.JTextField tx_hora;
    private javax.swing.JTextField tx_iva;
    private javax.swing.JTextField tx_nombrecli;
    public javax.swing.JTextField tx_numero;
    private javax.swing.JTextField tx_subtotal;
    private javax.swing.JTextField tx_telefonocli;
    private javax.swing.JTextField tx_totalcotizacion;
    // End of variables declaration//GEN-END:variables



}
